package com.tan00xu.controller;

import com.tan00xu.service.UserService;
import com.tan00xu.utils.CmdOutputInformationUtils;
import com.tan00xu.vo.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/user")
public class UserController {

    @Autowired
    private UserService userService;

    /**
     * 前端携带token来请求，并获取缓存中获取的当前用户信息
     * @param token 前端传入的token
     * @return Result
     */
    @GetMapping("/currentUser")
    public Result currentUser(@RequestHeader("Authorization") String token) {
        CmdOutputInformationUtils.info("UserController下的currentUser被请求了=>获取当前用户信息");
        return userService.getUserByToken(token);
    }

}
